<?php

namespace app\admin\model;

use think\Model;
use think\Db;
class Classifys extends Model
{
    protected $table = 'classify';

    public function index($where){
    	$list=db($this->table)->where($where)->paginate(5);
    	return $list;
    }
     public function add($data){
	 	Db::startTrans();
	 	$return = false;
        try{
             $res=db::table($this->table)->insertGetId($data);
             if($res){
             	 Db::commit();
             	 $return=$res;
             }         
        } catch (\Exception $e) {
            Db::rollback();
        }
        return $return;
	 }
	  public function edit($data){
	 	Db::startTrans();
	 	$return = false;
        try{
             $res=db::table($this->table)->where('id',$data['id'])->update($data);
             if($res){
             	 Db::commit();
             	 $return=true;
             }         
        } catch (\Exception $e) {
            Db::rollback();
        }
        return $return;
	 }
}
